/**
 */
package org.xtext.ic.dsl.icDsl.impl;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.MinimalEObjectImpl;

import org.xtext.ic.dsl.icDsl.Connection;
import org.xtext.ic.dsl.icDsl.DataBase;
import org.xtext.ic.dsl.icDsl.IcDslPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Connection</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.xtext.ic.dsl.icDsl.impl.ConnectionImpl#getType <em>Type</em>}</li>
 *   <li>{@link org.xtext.ic.dsl.icDsl.impl.ConnectionImpl#getDbname <em>Dbname</em>}</li>
 *   <li>{@link org.xtext.ic.dsl.icDsl.impl.ConnectionImpl#getUser <em>User</em>}</li>
 *   <li>{@link org.xtext.ic.dsl.icDsl.impl.ConnectionImpl#getPassword <em>Password</em>}</li>
 *   <li>{@link org.xtext.ic.dsl.icDsl.impl.ConnectionImpl#getUrl <em>Url</em>}</li>
 *   <li>{@link org.xtext.ic.dsl.icDsl.impl.ConnectionImpl#getPort <em>Port</em>}</li>
 *   <li>{@link org.xtext.ic.dsl.icDsl.impl.ConnectionImpl#getPoolsize <em>Poolsize</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class ConnectionImpl extends MinimalEObjectImpl.Container implements Connection
{
  /**
   * The cached value of the '{@link #getType() <em>Type</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getType()
   * @generated
   * @ordered
   */
  protected DataBase type;

  /**
   * The default value of the '{@link #getDbname() <em>Dbname</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDbname()
   * @generated
   * @ordered
   */
  protected static final String DBNAME_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getDbname() <em>Dbname</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getDbname()
   * @generated
   * @ordered
   */
  protected String dbname = DBNAME_EDEFAULT;

  /**
   * The default value of the '{@link #getUser() <em>User</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getUser()
   * @generated
   * @ordered
   */
  protected static final String USER_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getUser() <em>User</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getUser()
   * @generated
   * @ordered
   */
  protected String user = USER_EDEFAULT;

  /**
   * The default value of the '{@link #getPassword() <em>Password</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getPassword()
   * @generated
   * @ordered
   */
  protected static final String PASSWORD_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getPassword() <em>Password</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getPassword()
   * @generated
   * @ordered
   */
  protected String password = PASSWORD_EDEFAULT;

  /**
   * The default value of the '{@link #getUrl() <em>Url</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getUrl()
   * @generated
   * @ordered
   */
  protected static final String URL_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getUrl() <em>Url</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getUrl()
   * @generated
   * @ordered
   */
  protected String url = URL_EDEFAULT;

  /**
   * The default value of the '{@link #getPort() <em>Port</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getPort()
   * @generated
   * @ordered
   */
  protected static final String PORT_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getPort() <em>Port</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getPort()
   * @generated
   * @ordered
   */
  protected String port = PORT_EDEFAULT;

  /**
   * The default value of the '{@link #getPoolsize() <em>Poolsize</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getPoolsize()
   * @generated
   * @ordered
   */
  protected static final String POOLSIZE_EDEFAULT = null;

  /**
   * The cached value of the '{@link #getPoolsize() <em>Poolsize</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getPoolsize()
   * @generated
   * @ordered
   */
  protected String poolsize = POOLSIZE_EDEFAULT;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected ConnectionImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return IcDslPackage.Literals.CONNECTION;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public DataBase getType()
  {
    return type;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetType(DataBase newType, NotificationChain msgs)
  {
    DataBase oldType = type;
    type = newType;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, IcDslPackage.CONNECTION__TYPE, oldType, newType);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setType(DataBase newType)
  {
    if (newType != type)
    {
      NotificationChain msgs = null;
      if (type != null)
        msgs = ((InternalEObject)type).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - IcDslPackage.CONNECTION__TYPE, null, msgs);
      if (newType != null)
        msgs = ((InternalEObject)newType).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - IcDslPackage.CONNECTION__TYPE, null, msgs);
      msgs = basicSetType(newType, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, IcDslPackage.CONNECTION__TYPE, newType, newType));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getDbname()
  {
    return dbname;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setDbname(String newDbname)
  {
    String oldDbname = dbname;
    dbname = newDbname;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, IcDslPackage.CONNECTION__DBNAME, oldDbname, dbname));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getUser()
  {
    return user;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setUser(String newUser)
  {
    String oldUser = user;
    user = newUser;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, IcDslPackage.CONNECTION__USER, oldUser, user));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getPassword()
  {
    return password;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setPassword(String newPassword)
  {
    String oldPassword = password;
    password = newPassword;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, IcDslPackage.CONNECTION__PASSWORD, oldPassword, password));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getUrl()
  {
    return url;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setUrl(String newUrl)
  {
    String oldUrl = url;
    url = newUrl;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, IcDslPackage.CONNECTION__URL, oldUrl, url));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getPort()
  {
    return port;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setPort(String newPort)
  {
    String oldPort = port;
    port = newPort;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, IcDslPackage.CONNECTION__PORT, oldPort, port));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public String getPoolsize()
  {
    return poolsize;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setPoolsize(String newPoolsize)
  {
    String oldPoolsize = poolsize;
    poolsize = newPoolsize;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, IcDslPackage.CONNECTION__POOLSIZE, oldPoolsize, poolsize));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case IcDslPackage.CONNECTION__TYPE:
        return basicSetType(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case IcDslPackage.CONNECTION__TYPE:
        return getType();
      case IcDslPackage.CONNECTION__DBNAME:
        return getDbname();
      case IcDslPackage.CONNECTION__USER:
        return getUser();
      case IcDslPackage.CONNECTION__PASSWORD:
        return getPassword();
      case IcDslPackage.CONNECTION__URL:
        return getUrl();
      case IcDslPackage.CONNECTION__PORT:
        return getPort();
      case IcDslPackage.CONNECTION__POOLSIZE:
        return getPoolsize();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case IcDslPackage.CONNECTION__TYPE:
        setType((DataBase)newValue);
        return;
      case IcDslPackage.CONNECTION__DBNAME:
        setDbname((String)newValue);
        return;
      case IcDslPackage.CONNECTION__USER:
        setUser((String)newValue);
        return;
      case IcDslPackage.CONNECTION__PASSWORD:
        setPassword((String)newValue);
        return;
      case IcDslPackage.CONNECTION__URL:
        setUrl((String)newValue);
        return;
      case IcDslPackage.CONNECTION__PORT:
        setPort((String)newValue);
        return;
      case IcDslPackage.CONNECTION__POOLSIZE:
        setPoolsize((String)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case IcDslPackage.CONNECTION__TYPE:
        setType((DataBase)null);
        return;
      case IcDslPackage.CONNECTION__DBNAME:
        setDbname(DBNAME_EDEFAULT);
        return;
      case IcDslPackage.CONNECTION__USER:
        setUser(USER_EDEFAULT);
        return;
      case IcDslPackage.CONNECTION__PASSWORD:
        setPassword(PASSWORD_EDEFAULT);
        return;
      case IcDslPackage.CONNECTION__URL:
        setUrl(URL_EDEFAULT);
        return;
      case IcDslPackage.CONNECTION__PORT:
        setPort(PORT_EDEFAULT);
        return;
      case IcDslPackage.CONNECTION__POOLSIZE:
        setPoolsize(POOLSIZE_EDEFAULT);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case IcDslPackage.CONNECTION__TYPE:
        return type != null;
      case IcDslPackage.CONNECTION__DBNAME:
        return DBNAME_EDEFAULT == null ? dbname != null : !DBNAME_EDEFAULT.equals(dbname);
      case IcDslPackage.CONNECTION__USER:
        return USER_EDEFAULT == null ? user != null : !USER_EDEFAULT.equals(user);
      case IcDslPackage.CONNECTION__PASSWORD:
        return PASSWORD_EDEFAULT == null ? password != null : !PASSWORD_EDEFAULT.equals(password);
      case IcDslPackage.CONNECTION__URL:
        return URL_EDEFAULT == null ? url != null : !URL_EDEFAULT.equals(url);
      case IcDslPackage.CONNECTION__PORT:
        return PORT_EDEFAULT == null ? port != null : !PORT_EDEFAULT.equals(port);
      case IcDslPackage.CONNECTION__POOLSIZE:
        return POOLSIZE_EDEFAULT == null ? poolsize != null : !POOLSIZE_EDEFAULT.equals(poolsize);
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (dbname: ");
    result.append(dbname);
    result.append(", user: ");
    result.append(user);
    result.append(", password: ");
    result.append(password);
    result.append(", url: ");
    result.append(url);
    result.append(", port: ");
    result.append(port);
    result.append(", poolsize: ");
    result.append(poolsize);
    result.append(')');
    return result.toString();
  }

} //ConnectionImpl
